package me.maiz.babyisland.web;

import me.maiz.babyisland.dao.model.Category;
import me.maiz.babyisland.dao.model.Product;
import me.maiz.babyisland.service.ICategoryService;
import me.maiz.babyisland.service.IProductService;
import me.maiz.babyisland.service.info.CategoryInfo;
import lombok.extern.slf4j.Slf4j;
import me.maiz.babyisland.service.ICategoryService;
import me.maiz.babyisland.service.IProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.Collection;
import java.util.HashMap;
import java.util.List;

@Controller
@Slf4j
public class IndexController extends BaseController{

    @Autowired
    private ICategoryService categoryService;

    @Autowired
    private IProductService productService;


    @RequestMapping("/")
    public String index(ModelMap modelMap){
        //加载数据
        //1.加载分类 => 迁移到DataAdvice中处理


        //2.加载更多推荐
        List<Product> topSell = productService.findTopSell(10);
        modelMap.addAttribute("topSell",topSell);

        return "index2";
    }

    @RequestMapping("home")
    public String home(ModelMap modelMap){
        log.info("跳转到搜索...");
        return "forward:search";
    }


}
